package com.api.shopapi.mapper;

import com.api.shopapi.entity.DishesPlanChangeRecord;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface DishesPlanChangeRecordMapper {


    @Insert("insert into dishes_plan_change_record" +
            "(" +
            "DishesPlanChangeRecordCode," +
            "DishesPlanCode," +
            "CreateTime," +
            "Remarks," +
            "CarePlaceCode" +
            ") " +
            "values" +
            "(" +
            "#{dishesPlanChangeRecord.DishesPlanChangeRecordCode}," +
            "#{dishesPlanChangeRecord.DishesPlanCode}," +
            "#{dishesPlanChangeRecord.CreateTime}," +
            "#{dishesPlanChangeRecord.Remarks}," +
            "#{dishesPlanChangeRecord.CarePlaceCode}" +
            ")")
    int insert(@Param("dishesPlanChangeRecord") DishesPlanChangeRecord dishesPlanChangeRecord);

    @Update("update dishes_plan_change_record" +
            " set" +
            " Remarks=#{dishesPlanChangeRecord.Remarks}" +
            " where " +
            " DishesPlanChangeRecordCode=#{dishesPlanChangeRecord.DishesPlanChangeRecordCode}")
    int update(@Param("dishesPlanChangeRecord") DishesPlanChangeRecord dishesPlanChangeRecord);

    @Select("select * from dishes_plan_change_record where dishesPlanChangeRecord=#{dishesPlanChangeRecord} limit 1")
    DishesPlanChangeRecord getByDishesPlanChangeRecordCode(@Param("dishesPlanChangeRecord") String dishesPlanChangeRecord);

    @Select("<script>" +
            "select * from dishes_plan_change_record where carePlaceCode=#{carePlaceCode} order by createTime desc" +
            "</script>")
    List<DishesPlanChangeRecord> ListByCarePlaceCode(@Param("carePlaceCode") String carePlaceCode);

}
